From: Eusgor <100363036+Eusgor@users.noreply.github.com> Date: Thu, 29 May 2025 20:01:48 +0000 (+0600) Subject: [PATCH] src: fix possible dereference of null pointer X-Git-Tag: archive/raspbian/20.19.2+dfsg-1+rpi1+deb13u2^2~19 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/success//%22mailto:hdevalence%40gmail.com/%22/%22http:/www.example.com/cgi/success/%22mailto:hdevalence%40gmail.com/%22?a=commitdiff_plain;h=47edeff94f9429cb4b8096038967cf921f646ebc;p=nodejs.git [PATCH] src: fix possible dereference of null pointer There is a CHECK_NOT_NULL check before dereferencing node_env on line 710 in the "if" block, but there is no CHECK_NOT_NULL check before dereferencing node_env on line 721. Maybe it makes sense to put CHECK_NOT_NULL right after calling the Environment::GetCurrent function. PR-URL: https://github.com/nodejs/node/pull/58459 Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: Chengzhong Wu Gbp-Pq: Topic sec Gbp-Pq: Name 17-fix-possible-dereference-of-null-pointer.patch --- diff --git a/src/node_api.cc b/src/node_api.cc index d8a203ba4..34b2c1e5e 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -693,9 +693,9 @@ void napi_module_register_by_symbol(v8::Local exports, napi_addon_register_func init, int32_t module_api_version) { node::Environment* node_env = node::Environment::GetCurrent(context); + CHECK_NOT_NULL(node_env); std::string module_filename = ""; if (init == nullptr) { - CHECK_NOT_NULL(node_env); node_env->ThrowError("Module has no declared entry point."); return; }